#ifndef ITEMFOUNDDIALOG_H
#define ITEMFOUNDDIALOG_H

#include <functional>

#include <QDialog>
#include <QNetworkAccessManager>
namespace Ui{
    class ItemFoundDialog;
}
class QNetworkAccessManager;
class Item;
class ItemFoundDialog : public QDialog
{
    Q_OBJECT

public:
    ItemFoundDialog(const Item &item, QWidget *parent = nullptr);
    ~ItemFoundDialog();
public:
    // methods:
    inline QDialogButtonBox::StandardButton result()
    {
        return _result;
    }
private slots:
    void on_buttonBox_clicked(QAbstractButton *button);

private:
    void loadImageFromUrlAsync(const QString &url, std::function<void(QImage &img)> onFinished);
    QImage loadImageFromUrl(const QString &url);

private:
    QNetworkAccessManager manager;
    QDialogButtonBox::StandardButton _result;
private:
    Ui::ItemFoundDialog *ui;
};
#endif // ITEMFOUNDDIALOG_H
